﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using DrSoftsFrame.Servers;

namespace PreeRegisterDAL
{
    public class WorkMonitorDAL
    {
        /// <summary>
        /// 获取未发送排班数量 
        /// </summary>
        /// <param name="deptid"></param>
        /// <returns></returns>
        public static DataSet GetNotSendWorkNum(int SynWorkDay)
        {
            try
            {
                string sqlstr = string.Format(@"--查询未发送的排班修改
                                                select dupdate=convert(varchar(10),dupdatedate,120) into #temp
                                                from opdworkplan_update
                                                where dstarttime>=getdate() and dstarttime<convert(varchar(10),dateadd(dd,{0},getdate()),120)+' 0:00:00'
                                                and bsendflag=0 

                                                --按日期统计未发送的排班修改数
                                                select dupdate,count(1) num from #temp
                                                group by dupdate
                                                order by dupdate", SynWorkDay.ToString());
                ClinicDb mydb = new ClinicDb();
                DataSet ds = mydb.ExecuteSelect(sqlstr);
                if (ds == null || ds.Tables.Count < 1)
                {
                    return null;
                }
                ds.Tables[0].TableName = "WorkNum";
                return ds;

            }
            catch (Exception err)
            {

                throw;
            }
        }
    }
}
